package top.yueyazhui.ask_for_leave.task;

import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import top.yueyazhui.ask_for_leave.service.UserService;
import top.yueyazhui.ask_for_leave.util.BeanUtil;

import java.util.Map;

/**
 * 请假拒绝的服务类
 * @Author yueyazhui
 * @Date 2023/2/11
 */
@Slf4j
public class RejectServiceTask implements JavaDelegate {

    @Override
    public void execute(DelegateExecution delegateExecution) {
        Map<String, Object> variables = delegateExecution.getVariables();
        // 请假的用户
        String name = BeanUtil.getBean(UserService.class).getUsernameById(Integer.parseInt(variables.get("applicantId").toString()));
        // 请假的天数
        Integer days = ((Integer) variables.get("days"));
        log.info("{} 请假 {} 天的申请审批拒绝", name, days);
    }
}